﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using ATSBLL;

public partial class PIMTest_PIMTestMOCategory : System.Web.UI.Page
{
    private PIMTest Ptest;

     public PIMTest_PIMTestMOCategory()
    {
        Ptest = new PIMTest();
    }

    protected void Page_Load(object sender, EventArgs e)
    {

    }

    public void BindTests()
    {
        string moID = tbMONum.Text.Trim();
        GridView1.DataSource = Ptest.GetTestsbyMO(moID);
        GridView1.DataBind();
        for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            if (GridView1.Rows[i].Cells[8].Text == "Fail")
                GridView1.Rows[i].Cells[8].ForeColor = System.Drawing.Color.Red;
        }
    }

    protected void butSelect_Click(object sender, EventArgs e)
    {
        BindTests();
    }

    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        this.GridView1.PageIndex = e.NewPageIndex;
        BindTests();
    }

    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        string productSN = GridView1.SelectedDataKey["ProductSN"].ToString();
        Session["pIMRecordTime"] = Convert.ToDateTime(GridView1.SelectedDataKey["PIMRecordTime"]);
        //DateTime pIMRecordTime = Convert.ToDateTime(GridView1.SelectedDataKey["PIMRecordTime"]); "&pIMRecordTime=" + pIMRecordTime + 
        string productTypeID = GridView1.SelectedDataKey["ProductTypeID"].ToString();
        string userID = GridView1.SelectedDataKey["UserID"].ToString();
        string pIMENAID = GridView1.SelectedDataKey["PIM_ENAID"].ToString();
        string pIMPass = GridView1.SelectedDataKey["PIMPass"].ToString(); 
        Response.Redirect("../PIMTest/PIMTestDetails/ViewPIMTestItem.aspx?ProductSN=" + productSN + "&ProductTypeID=" + productTypeID + "&UserID=" + userID + "&PIM_ENAID=" + pIMENAID + "&PIMPass=" + pIMPass + ""); 
    }
}
